/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// Original output arithmetic
	/// </summary>
	[Serializable]
	public class SafeArithmetic: EQObject,  IBatchMode 
	{
		/// <summary>
		/// Ouput each cell of datatable to excel document one by one
		/// </summary>
		/// <param name="objRange"></param>
		/// <param name="objEQTableBase"></param>
		public void ArithmeticOutput(Excel.Range objRange, EQTableBase objEQTableBase)
		{
			int bottom = objEQTableBase.ItemTop + objEQTableBase.Table.Rows.Count - 1;	//Last row index
			int right = objEQTableBase.ItemLeft + objEQTableBase.Table.Columns.Count - 1;	//Last column index
			Excel.Worksheet objWorksheet = objRange.Worksheet;

			Excel.Range objCellRange = null;
			//Output each cell one by one
			for(int iRow=objEQTableBase.ItemTop; iRow<=bottom; iRow++)
			{
				for(int iCol=objEQTableBase.ItemLeft; iCol<=right; iCol++)
				{
					objCellRange = (Excel.Range)objWorksheet.Cells[iRow, iCol];
					if(objEQTableBase.ColumnsDataType[iCol] == EQType.Text)
						objCellRange.NumberFormatLocal = "@";
					objCellRange.Value = objEQTableBase.Table.Rows[iRow - objEQTableBase.ItemTop][iCol - objEQTableBase.ItemLeft];
				}
			}
		}
	}
}